<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .content {
            width: 1020px;
            display: flex;
            flex-wrap: wrap;
            margin: auto;
        }

        .content>div {
            width: 150px;
            height: 230px;
            background-color: green;
            margin: 10px;
            color: white;
        }
    </style>
</head>

<body>
    <div class="content">
    </div>


    <script>
        let number = 1;
        function showGoods(limit) {
            let content = '';
            for (let i = 0; i < limit; i++) {
                content += `<div>${number++}</div>`;
            }
            document.querySelector('.content').innerHTML += content;
        }
        showGoods(18);
        window.onscroll = function () {
            let timer=null;
            let y = 0;
            return function () {
                if(timer!=null){
                    clearTimeout(timer);
                }
                timer=setTimeout(function(){
                    //获取页面滚动的垂直距离
                    let sy = window.scrollY;
                    if (sy - y <= 0) {
                        //向上
                        return;
                    }
                    y = sy;
                    showGoods(6);
                    timer=null;
                },750);
                
            }
        }();
    </script>
</body>

</html>